﻿using System;
using System.Xml.Serialization;

namespace EpiNEXT.Services.Fields
{
    //[Serializable()]
    public abstract class OrientableListSelectorField : ListBoxField
    {
        #region Members
        private Orientation _orientation = Orientation.Vertical;
        private string _orientationString = "V";
        #endregion // Members

        #region Properties
        [XmlElement("Orientation")]
        public string OrientationString
        {
            get
            {
                return this._orientationString;
            }
            set
            {
                if (this.OrientationString != value)
                {
                    this._orientationString = value;
                    if (OrientationString.Equals("V"))
                    {
                        this.Orientation = Orientation.Vertical;
                    }
                    else
                    {
                        this.Orientation = Orientation.Horizontal;
                    }
                }
            }
        }

        [XmlIgnore]
        public Orientation Orientation
        {
            get 
            {
                return this._orientation;
            }
            set
            {
                if (this.Orientation != value)
                {
                    this._orientation = value;
                    if (Orientation.Equals(Orientation.Vertical))
                    {
                        this.OrientationString = "V";
                    }
                    else
                    {
                        this.OrientationString = "H";
                    }
                }
            }
        }
        #endregion // Properties

        #region Constructors
        public OrientableListSelectorField() 
            : base() 
        {
            Orientation = Orientation.Vertical;
            OrientationString = "V";
            InputWidth = Double.NaN;
            InputHeight = Double.NaN;
        }
        #endregion // Constructors
    }
}
